<?php
session_start();
require_once './model/users.php';
if(isset($_POST["submit"])){
    $params=array(
        "user_name"=>$_POST["username"],
        "password"=> md5($_POST["pass"])
        );
    $md_user=new users();
    $list_user=$md_user->select();
    $login=false;
    foreach ($list_user as $item):
            if(strcasecmp($params["user_name"],$item["name"])==0 && strcmp($params["password"],$item["password"])==0){
                    $_SESSION["id"]=$item["id"];
                    $login=true;
                    header("location:index.php");
            }
    endforeach;
    if(!$login)
        echo "Name or Pass?";    
}
?>
<?php if (isset( $_SESSION['id']) == NULL ): { ?>
<a style="color: #FFF; margin-left: 50px;">LOGIN</a>
<div  align="left" style="margin-left: 150px; margin-top: -30px" ><form method="POST">
        <p><a style="color: white">Username</a>
            <input type="text" name="username" placeholder="Username or Email"></p>
        <p style="margin-left: 4px"><a style="color: white">Password</a>
            <input type="password" name="pass" placeholder="password">
        <p style="margin-left: 150px"><input  type="submit" name="submit" value="Login">
    </form></div>
<?php } endif;?>
